<?php
function down()
{
	$name=$_GET["name"];
	
	//连接数据库
	$con = mysql_connect("localhost","root","");
		if (!$con)
 		 {
 		 die('Could not connect: ' . mysql_error());
		  }
		mysql_select_db("test", $con);
	$sql="select * from file where orginalname='".$name."'";
	
	$result=mysql_query($sql,$con);
	
	$row= mysql_fetch_array($result);
	
	$path=$row['path'];
	
	$file = fopen($path,"r");
    Header("Content-type: application/octet-stream");
	Header("Accept-Ranges: bytes");
	Header("Accept-Length: ".filesize($path));
	Header("Content-Disposition: attachment; filename=".$name);
	echo fread($file, filesize($path));
	fclose($file);
	
	
}
down();
?>